using System.Windows.Input;
using Archie.Retail.AdminTool.WpfFeatures;

namespace Archie.Retail.AdminTool.UI
{
    public abstract class EditorBase : NotificationObject, IEditor
    {
        /**********************************************************************************/
        // Declarations
        /**********************************************************************************/
        
        public ICommand AddCommand { get; private set; }
        public ICommand CancelCommand { get; private set; }
        public ICommand UpdateCommand { get; private set; }
        public ICommand SaveCommand { get; private set; }
        public ICommand DeleteCommand { get; private set; }

        /**********************************************************************************/
        // Functions
        /**********************************************************************************/
        
        protected EditorBase()
        {
            AddCommand = new RelayCommand(x=> OnAdd(), x => CanAdd());
            CancelCommand = new RelayCommand(x => OnCancel(), x => CanCancel());
            UpdateCommand = new RelayCommand(x => OnUpdate(), x => CanUpdate());
            SaveCommand = new RelayCommand(x => OnSave(), x => CanSave());
            DeleteCommand = new RelayCommand(x => OnDelete(), x => CanDelete());
        }

        /**********************************************************************************/

        protected abstract bool CanAdd();
        protected abstract void OnAdd();
        
        /**********************************************************************************/

        protected abstract bool CanUpdate();
        protected abstract void OnUpdate();
        
        /**********************************************************************************/
        
        protected abstract bool CanCancel();
        protected abstract void OnCancel();
        
        /**********************************************************************************/
        
        protected abstract bool CanSave();
        protected abstract void OnSave();
        
        /**********************************************************************************/

        protected abstract bool CanDelete();
        protected abstract void OnDelete();
        
        /**********************************************************************************/


    }
}